import { useUserStore } from '@/stores'

import type { ILoginInfo } from '@/types/login'
import { useMenuStore } from '@/stores/index'
export function saveLoginInfo(res: ILoginInfo) {
  let { token, tokenExpired } = res
  const userStore = useUserStore() ///
  //  持久化存储
  localStorage.setItem('token', token)
  localStorage.setItem('tokenExpired', tokenExpired)

  //   状态管理里

  //  vuex3

  userStore.saveToken({
    token,
    tokenExpired
  })
  let menuStore = useMenuStore() //

  return Promise.all([menuStore.getMenu(), userStore.getUserInfo()])
}
